package cn.efunbox.afw.core.util;

import cn.efunbox.afw.core.converter.BitConverter;

import java.util.UUID;

public class UUIDUtil {
 public UUIDUtil() {
 }

 public static String getUUID() {
  UUID uuid = UUID.randomUUID();
  StringBuilder temp=new StringBuilder(uuid.toString().substring(0, 8) + uuid.toString().substring(9, 13) + uuid.toString().substring(14, 18) + uuid.toString().substring(19, 23) + uuid.toString().substring(24));
  return temp.toString().toUpperCase();
 }
 //获得指定数量的UUID
 public static String[] getUUID(int number) {
  if (number < 1) {
   return null;
  }
  String[] ss = new String[number];
  for (int i = 0; i < number; i++) {
   ss[i] = getUUID();
  }
  return ss;
 }

 public static long getLongId()
 {
  byte[] buffer =   UUID.randomUUID().toString().getBytes();
  return BitConverter.toLong(buffer, 0);
 }
 public static void main(String[] args) {
  String[] ss = getUUID(10);
  /*for (int i = 0; i < ss.length; i++) {
   System.out.println("ss["+i+"]====="+ss[i]);
   System.out.println("ss["+i+"]====="+getLongId());
  }*/
  long start=System.currentTimeMillis();
  for(int i=0;i<50000;i++){
   System.out.println(UUIDUtil.getLongId());
  }
  System.out.println(System.currentTimeMillis()-start +"毫秒");
 }
}